//公共路由
export const commonRoutes = [{ path: '/guides', name: '使用指引', function_group: '/guides' }];
export const Reflection: any = {
  guowang1: [{ path: '/chatBot', name: '机器人', function_group: '/chatBot' }], //chatBot(5)
  guowang2: [{ path: '/chatBot', name: '机器人', function_group: '/chatBot' }], //chatBot(6)
  guowang3: [{ path: '/chatBot', name: '机器人', function_group: '/chatBot' }], //chatBot(8)
  chatglm: [{ path: '/chatBot', name: '机器人', function_group: '/chatBot' }], //dataDoc
  database: [
    { path: '/dataDoc', name: '数据库', function_group: '/dataDoc' },
    { path: '/spaceHome', name: 'AI大脑空间', function_group: '/spaceHome' },
    { path: '/spaceData', name: 'AI大脑空间', function_group: '/spaceData' },
    { path: '/importantTalk', name: '重要讲话空间', function_group: '/importantTalk' },
  ], //dataDoc
  gw_database: [{ path: '/dataQuestion', name: '数据库', function_group: '/dataQuestion' }], //dataQuestion
  article_generator: [
    { path: '/write', name: '写作共享实习生', function_group: '/write' },
    { path: '/writeHome', name: '写作共享实习生', function_group: '/writeHome' },
    { path: '/docList', name: '写作共享实习生', function_group: '/docList' },
    { path: '/allArticle', name: '写作共享实习生', function_group: '/allArticle' },
    { path: '/conversation', name: '写作共享实习生', function_group: '/conversation' },
    { path: '/conversationInit', name: '写作共享实习生', function_group: '/conversationInit' },
  ], // conversation
  ai_card: [{ path: '/visitingCard', name: 'AI名片', function_group: '/visitingCard' }], //visitingCard
};

export const functions_groups = [
  'article_generator',
  'database',
  'gw_database',
  'ai_card',
  'guowang1',
];

//根据groups组的权限 匹配到Reflection对应的路由+公共路由 = 用户可访问的路由
export const matchRoutesGroups = (groups: []) => {
  let list: any = [];
  groups.forEach((item: any) => {
    list = list.concat(Reflection[item] || []);
  });
  //去除重复的路由
  list = list.reduce((prev: any, cur: any) => {
    const hasCur = prev.find((item: any) => item.path === cur.path);
    return hasCur ? prev : prev.concat(cur);
  }, []);
  let allList = list.concat(commonRoutes);
  return allList;
};
